package com.itheima.reggie.mappers;

import com.itheima.reggie.entity.Setmeal;
import com.itheima.reggie.entity.dto.SetmealDto;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface SetmealMapper {
    @Select("SELECT COUNT(*) FROM setmeal WHERE category_id=#{id}")
    Integer selectByCategoryId(Long id);

    @Insert("insert into setmeal values(null,#{categoryId},#{name},#{price}," +
                    "#{status},#{code},#{description},#{image},#{createTime}," +
                    "#{updateTime},#{createUser},#{updateUser},0)")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void save(SetmealDto setmealDto);

    List<Setmeal> findByName(String name);

    Integer findCountByStatus(@Param("ids") Long[] ids);

    void delete(Long[] ids);

    @Select("select * from setmeal where id=#{id}")
    Setmeal findById(Long id);

    void update(SetmealDto setmealDto);

    void updateStatus(@Param("ids") List<Long> ids,@Param("status") int status);

    @Select("select * from setmeal where category_id=#{categoryId} and status=#{status}")
    List<Setmeal> findByCategoryId(Long categoryId, int status);
}
